package com.meritdata.cloud.data.service.development.service;

import com.meritdata.cloud.data.service.development.model.QTdDataApiResultFiled;
import com.meritdata.cloud.data.service.development.model.QTdDataApiTable;
import com.meritdata.cloud.data.service.development.model.TdDataApiResultFiled;
import com.meritdata.cloud.data.service.development.model.TdDataApiTable;
import com.meritdata.cloud.data.service.development.repository.IDataApiResultFiledDao;
import com.meritdata.cloud.data.service.development.repository.IDataApiTableDao;
import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DataApiResultFiledService {
    @Autowired
    private JPAQueryFactory jpaQueryFactory;

    @Autowired
    private IDataApiResultFiledDao iDataApiResultFiledDao;
    public boolean save(TdDataApiResultFiled category) {
        iDataApiResultFiledDao.save(category);
        return true;
    }

    public List<TdDataApiResultFiled> findByApiId(Long apiId) {
        QTdDataApiResultFiled qTdDataApiResultFiled = QTdDataApiResultFiled.tdDataApiResultFiled;
        Predicate predicate =qTdDataApiResultFiled.apiId.eq(apiId);
        return jpaQueryFactory.selectFrom(qTdDataApiResultFiled)
                .where(predicate)
                .fetch();
    }
    public Boolean deleteByApiId(Long apiId) {
        return iDataApiResultFiledDao.deleteByApiId(apiId)>=0;
    }
}
